package china.lzy.entity;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author ：lzy
 * @ Date       ：Created in 14:58 2021/8/9
 * @ Description：
 */
@Data
public class ResResult<T> {
    //操作结果编码
    private Integer code;
    //操作数据结果
    private T data;
    //操作数据消息
    private String message;

    public ResResult(Integer code, T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public ResResult(T data, ResCode resCode) {
        this.data = data;
        this.code = resCode.getCode();
        this.message = resCode.getMessage();
    }

    public ResResult(ResCode resCode) {
        this.code = resCode.getCode();
        this.message = resCode.getMessage();
    }

    public ResResult(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
    public ResResult(ResCode resCode, String message) {
        this.code = resCode.getCode();
        this.message = message;
    }
    public static ResResult ResResultBuilder(ResCode resCode,String message) {
        return new ResResult(resCode,message);
    }
    public static ResResult ResResultBuilder(ResCode resCode) {
        return new ResResult(resCode);
    }

    public static ResResult ResResultBuilder(Integer code, String message) {
        return new ResResult(code, message);
    }

    public static ResResult ResResultBuilder(Integer code, Object data, String message) {
        return new ResResult(code, data, message);
    }

    public static ResResult ResResultBuilder(Object data, ResCode resCode) {
        return new ResResult(data, resCode);
    }

}
